package com.min.gps.service.impl;

import com.min.gps.service.Response;
import com.min.gps.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * Created by mincx
 */
@Service("webSocketService")
public class WebSocketServiceImpl  implements WebSocketService {
 @Autowired
    //使用SimpMessagingTemplate 向浏览器发送消息
    private SimpMessagingTemplate template;

public void sendMessage(String str) throws Exception{
      Thread.sleep(1000);
   template.convertAndSend("/topic/getResponse",new Response(str));
  }

}